package com.mdlib.helper.ui.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljlib.core.util.common.TimeUtils;
import com.ljlib.help.R;
import com.mdlib.helper.model.entity.BuyEntity;
import com.mdlib.helper.utils.GlideCircleTransform;

import java.util.List;

/**
 * 作者：HQY on 16/12/19 13:48
 * 邮箱：hqy_xz@126.com
 */

public class SendBuyAdapter extends BaseQuickAdapter<BuyEntity> {

    public SendBuyAdapter(List<BuyEntity> data) {
        super(R.layout.item_send_buy, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, BuyEntity buy) {

        baseViewHolder.setText(R.id.tv_buy_goods_name, buy.getGoods_name())
                .setText(R.id.tv_buy_goods_remark, buy.getRemark())
                .setText(R.id.tv_buy_goods_phone, buy.getPhone())
                .setText(R.id.tv_buy_goods_address, buy.getAddress())
                .setText(R.id.tv_buy_service_money, "￥" + buy.getTotal_money())
                .setText(R.id.tv_buy_time, TimeUtils.milliseconds2String(Long.valueOf(buy.getCreated_at()) * 1000));
        Glide.with(mContext)
                .load(buy.getImg_path())
                .placeholder(R.drawable.iv_send_buy)
                .error(R.drawable.iv_send_buy)
                .transform(new GlideCircleTransform(mContext))
                .into((ImageView) baseViewHolder.getView(R.id.iv_buy_goods_pic));
    }
}
